package com.xnfh.home.viewmodel

import com.xnfh.common.bean.NzGlBean
import com.xnfh.framework.base.BaseViewModel
import com.xnfh.framework.bean.RespStateData
import org.json.JSONObject

/**
 * @Description:
 * @Author: ziheng
 * @CreateDate: 2023/12/28 18:04
 * @UpdateUser: ziheng
 * @UpdateDate: 2023/12/28 18:04
 * @UpdateRemark: 更新说明
 */
class AgriculturalGlViewModel : BaseViewModel() {
    private val agriculturalGlViewModelRes = AgriculturalGlViewModelRes()
    val nzList = RespStateData<NzGlBean>()

    /**
     * 获取农资管理列表
     */
    fun requestNzList(page: Int, type: Int?, keywords: String?) = launch {
        val jsonObject = JSONObject()
        jsonObject.put("current", page)
        jsonObject.put("size", 20)
        jsonObject.put("agriType", type)//(0-农药 1-化肥  2-种子 3-人工 4-全部)
        keywords?.let {
            jsonObject.put("productionName", keywords)
        }
        agriculturalGlViewModelRes.requestNzList(creatRequestBody(jsonObject.toString()), nzList)
    }
}